﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Umbrella.Whs.SharePoint;

namespace Umbrella.Whs.WhsAddin.Wizards.SharePointInstallation
{
    internal class InstallStepConfigDbAndCentralAdmin : IInstallStep
    {
        private DatabaseManager _dbm = new DatabaseManager();

        public string Title
        {
            get { return Resources.txtConfiguringSharePoint; }
        }

        public int Weight
        {
            get { return 180; }
        }

        public void PerformInstall()
        {
            var sa = SharePointServiceAccount.Load();

            var pi = new RunPsConfig(
                "-cmd configdb -server \"" + _dbm.SqlServerName + "\" " +
                "-create -database WSS_Config -user \"" + sa.UserName + "\" " +
                "-password \"" + sa.Password.ToClrString() + "\" -admincontentdatabase WSS_Content_CentralAdmin"
                );

            pi.Run();
        }
    }
}
